package main

import (
	"encoding/json"
	"fmt"
)

type Person struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
}
type People Person

func main() {
	var person Person
	var people People
	person = Person(people) //people = Person(people) 这样是错误的
	fmt.Println(person)
	fmt.Println(people)
	people.Name = "Ryan"
	people.Age = 29
	jsonPeople, err := json.Marshal(people)
	if err != nil {
		fmt.Println("json错误")
	} else {
		fmt.Printf("%T \n", jsonPeople) //jsonPeople是个切片
	}
	jsonPeople1 := string(jsonPeople) //字符串底层就是切片
	fmt.Println(jsonPeople1)
}
